<{include file="Public/top.html" }>
</head>
<body>
<div id="warpper">
    <div class="content">
        <div class="location">套餐管理</div>
        <{include file= "Business/nav.html"}>

        <div class="filedSet" style="padding-bottom: 0;">
            <div class="search">
                <form action="" method="get" class="ui-form reportForm" id="searchForm">
                    <input name="m" type="hidden" value="<{$module}>">
                    <input name="c" type="hidden" value="<{$controller}>">
                    <input name="a" type="hidden" value="<{$action}>">

                    <input name="p" id="page" type="hidden" value="<{$page|default:1}>">
                    <input name="limit" id="limit" type="hidden" value="<{$limit|default:10}>">
                    <input name="ofield" id="ofield" type="hidden" value="<{$ofield}>">
                    <input name="otype"  id="otype"  type="hidden" value="<{$otype}>">

                    <div class="ui-form-item inline-block">
                        <label class="ui-label">所属商户</label>
                        <select name="restaurantId" id="restaurantId" class="ui-select" style="width: 160px;">
                            <option value="0">全部</option>
                            <{html_options options=$restaurantKV selected=$id}>

                        </select>
                    </div>
                    <div class="ui-form-item inline-block">
                        <label class="ui-label">所属门店</label>
                        <select name="storeId" id="storeId" class="ui-select" style="width: 160px;">
                            <option value="0">全部</option>
                        </select>
                    </div>
                    <div class="ui-form-item inline-block">
                        <button type="submit" id="search" class="ui-button" onclick="LayerShow();">查询</button>
                    </div>
                    <div class="ui-form-item inline-block">
                        <button type="button" id="addStoreBtn" class="ui-button" onclick="LayerShow();">添加套餐</button>
                    </div>

                </form>
            </div>
        </div>
        <!--表格内容-->
        <div class="mainGrid">
            <table class="ui-table ui-body">
                <thead>
                    <tr>
                        <th class="pct15">套餐名称</th>
                        <th class="pct15">添加时间</th>
                        <th class="pct20">关联商家</th>
                        <th class="pct10">显示排序</th>
                        <th class="pct10">原价</th>
                        <th class="pct10">现价</th>
                        <th class="pct10">状态</th>
                        <th class="pct10">操作</th>

                    </tr>
                </thead>
                <tbody>
                <{foreach from=$list item=item}>
                <tr>
                    <td><a href="<{$WEBSITE}>wap.php?m=Wap&c=Business&a=packageDetail&id=<{$item.id}>" target="_blank"><{$item.title}></a></td>
                    <td><{$item.addTime|date_format:"%Y-%m-%d %H:%M"}></td>
                    <td><{$restaurantKV[$item.restaurantId]}><br /><{$storeKV[$item.storeId]}></td>
                    <td><{$item.showOrder}></td>
                    <td><{$item.priceOriginal}></td>
                    <td><{$item.pricePresent}></td>
                    <td><{if $item.status == $smarty.const.ENABLE_ENABLE}>已上架<{else}>未上架<{/if}></td>
                    <td class="ta_l">
                        <div class="handler">
                            <a href="<{u('storePackageEdit?id='|cat:$item['id'])}>" onclick="LayerShow();">修改</a>
                            <span class="sep">|</span>
                            <{if $item.status == $smarty.const.ENABLE_ENABLE}>
                                <a href="<{u('storePackageAudit?status=2&id='|cat:$item['id'])}>" onclick="if(!confirm('确定下架该套餐么？'))return false;">下架</a>
                            <{else}>
                                <a href="<{u('storePackageAudit?status=1&id='|cat:$item['id'])}>" onclick="if(!confirm('确定上架该套餐么？'))return false;">上架</a>
                            <{/if}>
                            <span class="sep">|</span>
                            <a href="<{u('storePackageDel?id='|cat:$item['id'])}>" onclick="LayerShow();">删除</a>
                        </div>
                    </td>
                </tr>
                <{/foreach}>
                </tbody>
            </table>
        </div>
        <!--描述：分页-->
        <div class="pagination">
            <{include file="Public/page.html"}>
        </div>
    </div>
</div>
<script>
    $('#addStoreBtn').click(function(){
                location.href="<{u('storePackageAdd')}>";
    });

    $(document).ready(
            function(){
                $('#restaurantId').on('change',function(){
                    var restaurantId=$('#restaurantId').val();
                    $.getJSON("./api.php?m=Api&c=Business&a=getStoreListByRestaurantId",{id:restaurantId,partner:1},function(data){
                        if(data){
                            var $store=$("#storeId");
                            $store.empty().append("<option value='0'>全部</option>");
                            $.each(data.data,function(i,item){
                                $store.prepend("<option value='" + item.id + "'>" + item.storeName + "</option>");
                            });
                        }
                    });
                });
            }

    );
</script>
</body>
<{include file="Public/foot.html" }>